package com.example.goodsass.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.goodsass.domain.Goodsass;
import com.example.goodsass.mapper.GoodsassMapper;
import com.example.goodsass.service.TgoodsService;
import com.example.goodsass.domain.Tgoods;
import com.example.goodsass.mapper.TgoodsMapper;
import com.example.goodsass.vo.goodsVO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 31673
 * @description 针对表【tgoods】的数据库操作Service实现
 * @createDate 2025-04-05 19:53:44
 */
@Service
public class TgoodsServiceImpl extends ServiceImpl<TgoodsMapper, Tgoods>
        implements TgoodsService {
    @Resource
    private TgoodsMapper tgoodsMapper;

    @Resource
    private GoodsassMapper goodsassMapper;

    @Override
    public goodsVO getGoodsByNo(int Goods_No) {
        Tgoods tgoods = tgoodsMapper.selectById(Goods_No);
        Goodsass goodsass = goodsassMapper.queryByNo(Goods_No);
        goodsVO goodsVO = new goodsVO();
//        goodsVO.setTgoodsList(goodsList);
//        goodsVO.setGoodsassList(goodsAssList);
        goodsVO.setTgoods(tgoods);
        goodsVO.setGoodsass(goodsass);
        return goodsVO;
    }

    @Override
    public goodsVO selGoodsInfo() {
        goodsVO goodsVO = new goodsVO();
        List<Tgoods> goodsList = tgoodsMapper.selectList(null);
        List<Goodsass> goodsAssList = goodsassMapper.selectList(null);
        goodsVO.setTgoodsList(goodsList);
        goodsVO.setGoodsassList(goodsAssList);
        return goodsVO;
    }

    @Override
    public String delGoodsInfo(int Goods_No) {
        tgoodsMapper.delGoodsInfoByNo(Goods_No);
        return "删除成功，商品编号：" + Goods_No;
    }

    @Override
    public String insGoodsInfo(Tgoods tgoods) {
        tgoodsMapper.insGoodsInfoByNo(tgoods);
        return "插入成功，商品编号：" + tgoods.getGoodsNo();
    }

    @Override
    public String updGoodsInfo(Tgoods tgoods) {
        tgoodsMapper.updGoodsInfoByNo(tgoods);
        return "更新成功，商品编号：" + tgoods.getGoodsNo();
    }
}




